<template>
    <view>
        <u-navbar title="充值记录"></u-navbar>
        <view class="record-wrap">
            <edu-mescroll-body
                height="calc(100vh - 44px)"
                @init="mescrollInit"
                @down="refresh"
                @up="reachBottom"
            >
                <view
                    class="item"
                    v-for="(item, index) in vipRecordList"
                    :key="index"
                >
                    <view class="top u-border-bottom">
                        <view class="name">
                            <u-image
                                width="30rpx"
                                height="26rpx"
                                src="@/static/images/vip_icon.png"
                            ></u-image>
                            {{ item.ext_data.vip_title }}
                        </view>
                        <view class="price">{{
                            item.payment | formatCurrency
                        }}</view>
                    </view>
                    <view class="bottom">
                        <view class="view">
                            <text class="label">订单编号：</text>
                            <text class="text">{{ item.order_no }}</text>
                        </view>
                        <view class="view">
                            <text class="label">充值时间：</text>
                            <text class="text">{{
                                item.payment_time | timeFormat
                            }}</text>
                        </view>
                        <view class="view">
                            <text class="label">有效期至：</text>
                            <text class="text">{{
                                item.expire_time | timeFormat
                            }}</text>
                        </view>
                    </view>
                </view>
            </edu-mescroll-body>
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            vipRecordList: [],
        };
    },
    methods: {
        reachBottom(page) {
            this.$edu.api
                .getUserVipLog({
                    page: page.num,
                    count: page.size,
                })
                .then((res) => {
                    const { data } = res;

                    let list = data.data;
                    let total = data.total;

                    if (page.num == 1) this.vipRecordList = [];
                    this.vipRecordList = this.vipRecordList.concat(list);
                    this.mescroll.endBySize(list.length, total);
                });
        },
        refresh() {
            this.mescroll.resetUpScroll();
        },
    },
};
</script>

<style lang="scss" scoped>
.record-wrap {
    padding: 14rpx 0;
    min-height: calc(100vh - 44px);
    background-color: #ffffff;
    .item {
        margin-top: 32rpx;
        margin-left: 30rpx;
        margin-right: 30rpx;
        box-shadow: 0px 2px 24px 0px rgba(0, 0, 0, 0.08);
        border-radius: 8px;
        .top {
            padding: 15rpx 25rpx;
            display: flex;
            align-items: center;
            .name {
                font-size: 30rpx;
                font-weight: 500;
                color: $edu-main-color;
                display: flex;
                align-items: center;
            }
            .price {
                margin-left: auto;
                font-size: 28rpx;
                font-weight: 400;
                color: $edu-tips-color;
            }
        }
        .bottom {
            padding: 0 25rpx 34rpx;
            .view {
                margin-top: 24rpx;
                font-size: 28rpx;
                font-weight: 400;
                .label {
                    color: $edu-content-color;
                }
                .text {
                    color: $edu-tips-color;
                }
            }
        }
    }
}
</style>
